package org.microsites.service;

import java.util.List;

import org.microsites.domain.model.Entity;
import org.microsites.security.Locking;
import org.microsites.security.Secured;
import org.microsites.security.Locking.Operation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(propagation=Propagation.SUPPORTS)
public interface GenericService<T extends Entity> {

	@Secured
	public List<T> list();
	
	@Secured
	public List<T> sublist(Long id);
	
    @Secured
    public T load(Long id);

    @Secured
    public List<Entity> loadPath(Long id);

	@Secured
	@Locking(Operation.LOCK)
	public T edit(Long id);

	@Secured
	@Locking(Operation.RELEASE)
	public void release(Long id);

	@Secured
	@Locking(Operation.KEEP)
	public void keep(Long id);

	@Secured
	@Transactional(propagation=Propagation.REQUIRED)
	public void create(T entity);
	
	@Secured
	@Transactional(propagation=Propagation.REQUIRED)
	@Locking(Operation.RELEASE)
	public void update(T entity);
	
	@Secured
	@Transactional(propagation=Propagation.REQUIRED)
	public void delete(Long id);

	@Secured
	public List<String> autocomplete(String column, String pattern);
}
